<?php

/** Zend_Validate_Abstract */
require_once 'Zend/Validate/Abstract.php';

class WSB_Validator_EmailAddressSimple extends Zend_Validate_Abstract
{
    const INVALID = 'emailAddressSimpleInvalid';

    /**
     * @var array
     */
	protected $_messageTemplates = array(
        self::INVALID => "'%value%' is not a valid email address",
    );

    /**
     * @param string $value
     * @param array $context
     * @return boolean
     */
    public function isValid($value, $context = null)
    {
    	$value = trim($value);
        $this->_setValue($value);
		if (strpos($value, ' ') !== false) {
			$this->_error(self::INVALID);
			return false;
		}
		if(!ereg('^[A-Za-z0-9\._-]+[@][A-Za-z0-9\._-]+[\.].[A-Za-z0-9]+$', $value)) {
			$this->_error(self::INVALID);
			return false;
		}
		return true;
    }

}